package br.feevale.ihc

import br.com.insoft4.ext.rest.AbstractCrudService
import br.com.insoft4.extjs.rest.AbstractCrudController
import br.com.insoft4.insoftextui.export.CSVFileHelperIntf

class ProjetoController extends AbstractCrudController<Projeto> {
	
	ProjetoService projetoService
	def csvFileHelper
	
	@Override
	protected AbstractCrudService<Projeto> getCrudService() {
		return projetoService
	}

	@Override
	protected CSVFileHelperIntf getCsvHelper() {
		return csvFileHelper
	}
	
	def gen() {
		String codPrograma = "IHC001"
		String namespace = "IHC"
		String dir = "C:/Users/richard/Documents/Pessoal/Feevale/projetos/ihc-analise-produtividade/web-app/app/app/"

		StringBuilder content = new StringBuilder()

		def domainClass = grailsApplication.getDomainClass(Projeto.class.name)
		content << gen.model(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, diretorio: dir)
		content << gen.store(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, diretorio: dir)

		content << gen.gridView(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, isDetail: false, isMaster: true, diretorio: dir)
		content << gen.formView(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, isDetail: false, isMaster: true, diretorio: dir)
		content << gen.listController(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, isDetail: false, isMaster: true, detailFilterName: 'projetoFilter', diretorio: dir)
		content << gen.formController(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, isDetail: false, isMaster: true, diretorio: dir)

		domainClass = grailsApplication.getDomainClass(Atividade.class.name)

		content << gen.model(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, diretorio: dir)
		content << gen.store(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, diretorio: dir)
		content << gen.gridView(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, sufix: 'Detail', isDetail: true, isMaster: false, diretorio: dir)
		content << gen.formView(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, sufix: 'Detail', isDetail: true, isMaster: false, diretorio: dir)
		content << gen.listController(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, sufix: 'Detail', masterController: 'self', isDetail: true, isMaster: false, diretorio: dir)
		content << gen.formController(programa: codPrograma, domainClass: domainClass, extNamespace: namespace, sufix: 'Detail', isDetail: true, isMaster: false, diretorio: dir)

		render text: content.toString(), contentType: 'text/plain'
	}

	
}
